package com.yanqu.road.server.logic.bag;

import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.entity.bag.UseGoodsResult;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.EarnSpeedModule;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.math.BigInteger;

/**
 * 赚钱卡，获取时间内的收益
 */
public class UseAddSilver extends BaseUseGoods {

	public UseAddSilver(GamePlayer player, GoodsInfo goodsInfo, long param) {
		super(player, goodsInfo, param);
	}

	@Override
	int checkUse(long count) {
		return 0;
	}

	@Override
	UseGoodsResult executeUse(long count) {
		UseGoodsResult result = new UseGoodsResult();
		BigInteger earnSpeed = player.getModule(EarnSpeedModule.class).getEarnSpeed();
		long goodsParam = goodsInfo.getParamList().get(0).longValue();
		BigInteger addSilver = earnSpeed.multiply(BigInteger.valueOf(goodsParam)).multiply(BigInteger.valueOf(count));

		Property addProperty = new Property(GameConfig.GAME_MONEY_SILVER, addSilver);
		player.getModule(CurrencyModule.class).addCurrency(addProperty, eLogMoneyType.Bag, eLogMoneyType.BagUseGetReward);
		result.setReward(PropertyHelper.parsePropertyToString(addProperty));
		return result;
	}
}
